package cn.ultrarisk.scadmin.manager.biz.solr.entity;

import cn.ultrarisk.mybatis.extension.annotation.Table;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * solr集合实体类
 *
 * @author sevendlong(lin23871@163.com)
 * @date 2014/4/14
 * @since V1.0
 */
@Table(table = "solr_collection", idColumn = SolrCollection.ID, autoIncrement = true)
public class SolrCollection implements Serializable {
    private static final long serialVersionUID = -3757808734334795000L;

    public final static String ID = "id";
    public final static String NAME = "name";
    public final static String UNIQUE_KEY = "unique_key";
    public final static String CONFIG = "config";
    public final static String ROUTER = "router";
    public final static String ALLOW_COMMIT = "allow_commit";
    public final static String ALLOW_ROLLBACK = "allow_rollback";
    public final static String MAX_START = "max_start";
    public final static String MAX_LIMIT = "max_limit";
    public final static String REMARK = "remark";
    public final static String AVAILABLE = "available";
    public final static String UPDATE_TIME = "update_time";

    public static final Map<String, String> COLUMN_PROPERTY_MAP = new LinkedHashMap<String, String>();

    static {
        COLUMN_PROPERTY_MAP.put(ID, "id");
        COLUMN_PROPERTY_MAP.put(NAME, "name");
        COLUMN_PROPERTY_MAP.put(UNIQUE_KEY, "uniqueKey");
        COLUMN_PROPERTY_MAP.put(CONFIG, "config");
        COLUMN_PROPERTY_MAP.put(ROUTER, "router");
        COLUMN_PROPERTY_MAP.put(ALLOW_COMMIT, "allowCommit");
        COLUMN_PROPERTY_MAP.put(ALLOW_ROLLBACK, "allowRollback");
        COLUMN_PROPERTY_MAP.put(MAX_START, "maxStart");
        COLUMN_PROPERTY_MAP.put(MAX_LIMIT, "maxLimit");
        COLUMN_PROPERTY_MAP.put(REMARK, "remark");
        COLUMN_PROPERTY_MAP.put(AVAILABLE, "available");
        COLUMN_PROPERTY_MAP.put(UPDATE_TIME, "updateTime");
    }

    /**
     * id
     */
    private Integer id;
    /**
     * 集合名称
     */
    private String name;
    /**
     * 主键
     */
    private String uniqueKey;
    /**
     * 配置文件
     */
    private String config;
    /**
     * 文档路由
     */
    private String router;
    /**
     * 是否允许提交
     */
    private Boolean allowCommit;
    /**
     * 是否允许回滚
     */
    private Boolean allowRollback;
    /**
     * 分页起始最大值
     */
    private Integer maxStart;
    /**
     * 分页每页记录数最大值
     */
    private Integer maxLimit;
    /**
     * 是否有效
     */
    private Boolean available;
    /**
     * 描述
     */
    private String remark;
    /**
     * 更新时间
     */
    private Long updateTime;
    /**
     * 分片
     */
    private List<SolrShard> shards;

    public SolrCollection() {
    }

    public SolrCollection(String name, String config) {
        this.name = name;
        this.config = config;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUniqueKey() {
        return uniqueKey;
    }

    public void setUniqueKey(String uniqueKey) {
        this.uniqueKey = uniqueKey;
    }

    public String getConfig() {
        return config;
    }

    public void setConfig(String config) {
        this.config = config;
    }

    public String getRouter() {
        return router;
    }

    public void setRouter(String router) {
        this.router = router;
    }

    public Boolean getAllowCommit() {
        return allowCommit;
    }

    public void setAllowCommit(Boolean allowCommit) {
        this.allowCommit = allowCommit;
    }

    public Boolean getAllowRollback() {
        return allowRollback;
    }

    public void setAllowRollback(Boolean allowRollback) {
        this.allowRollback = allowRollback;
    }

    public Integer getMaxStart() {
        return maxStart;
    }

    public void setMaxStart(Integer maxStart) {
        this.maxStart = maxStart;
    }

    public Integer getMaxLimit() {
        return maxLimit;
    }

    public void setMaxLimit(Integer maxLimit) {
        this.maxLimit = maxLimit;
    }

    public Boolean getAvailable() {
        return available;
    }

    public void setAvailable(Boolean available) {
        this.available = available;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }

    public List<SolrShard> getShards() {
        return shards;
    }

    public void setShards(List<SolrShard> shards) {
        this.shards = shards;
    }

    public void addShard(SolrShard shard) {
        if (this.shards == null) {
            this.shards = new ArrayList<SolrShard>();
        }
        this.shards.add(shard);
    }
}